package com.situ.day11;

import java.awt.GridLayout;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;

public class ComboBoxDemo {

	public static void main(String[] args) {
		JFrame frame = new JFrame("CalDemo");
//		frame.setTitle("BorderLayout");
		JPanel panel = new JPanel();
		frame.add(panel);
		panel.setLayout(new GridLayout(2, 1));

		JPanel comboPanel = new JPanel();
		JLabel comboLabel = new JLabel("你的籍贯：");
		String[] homes = new String[] { "北京", "青岛", "济南", "上海" };
//		JComboBox comboBox = new JComboBox(homes);
		JComboBox<String> comboBox = new JComboBox<String>(homes);
		comboPanel.add(comboLabel);
		comboPanel.add(comboBox);
		panel.add(comboPanel);

		JPanel listPanel = new JPanel();
		JLabel lisLabel = new JLabel("学习语言：");
		String[] languages = new String[] { "Java", "PHP", "Python", "Android", "C", "C#" };
//		JList lists = new JList(languages);
		JList<String> lists = new JList<String>(languages);
		listPanel.add(lisLabel);
		listPanel.add(lists);
		panel.add(listPanel);

		// 设置JFrame属性
		// 禁止用户改变窗口大小 resize able 能够
		frame.setResizable(false);
		frame.setSize(400, 300);
		frame.setLocation(500, 200);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

}
